package main

import (
	"fmt"
	"gitee.com/baal1990/epidemic/global"
	"gitee.com/baal1990/epidemic/initialize"
	"os"
)

func main() {
	args := os.Args
	if len(args) == 0 || len(args) != 3 {
		fmt.Println("usage: -e encrypt")
		fmt.Println("       -d decrypt")
		return
	}
	cryptoMethod := args[1]
	content := args[2]
	initialize.InitSymmetricCrypto()
	switch cryptoMethod {
	case "-e":
		result, err := global.SymmetricCrypto.EncryptWithBase64([]byte(content))
		if err != nil {
			fmt.Println(err)
			return
		}
		fmt.Println("[", result, "]")
	case "-d":
		result, err := global.SymmetricCrypto.DecryptWithBase64(content)
		if err != nil {
			fmt.Println(err)
			return
		}
		fmt.Println("[", string(result), "]")
	}
}
